package com.woyou.ui.adapter;

import java.util.List;

import com.citaq.ideliver.R;
import com.woyou.bean.Goods;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ReturnOrderAdapter extends BaseAdapter {
	private Context context;
	private List<Goods> goodsList;
	private LayoutInflater layoutInflater;

	public ReturnOrderAdapter(Context context, List<Goods> goodsList) {
		this.context = context;
		layoutInflater = LayoutInflater.from(context);
		this.goodsList = goodsList;
	}

	@Override
	public int getCount() {
		return goodsList.size();
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			convertView = layoutInflater.inflate(R.layout.item_returnorder_lv, null);
			viewHolder = new ViewHolder();
			viewHolder.name = (TextView) convertView.findViewById(R.id.returnorder_name);
			viewHolder.info=(TextView)convertView.findViewById(R.id.returnorder_info);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.name.setText("" + goodsList.get(position).getgName());
		if(goodsList.get(position).getState()==1){
			viewHolder.info.setText("正常");
		}else if(goodsList.get(position).getState()==2){
			viewHolder.info.setText("暂缺, 请移除");
		}else if(goodsList.get(position).getState()==3){
			viewHolder.info.setText("下架, 请移除");
		}else if(goodsList.get(position).getState()==4){
			viewHolder.info.setText("金额有变, 请核对");
		}else if(goodsList.get(position).getState()==5){
			viewHolder.info.setText("不存在, 请移除");
		}
		return convertView;
	}

	static class ViewHolder {
		TextView name;
		TextView info;
	}
}
